package com.xu.crawler.dao.impl;

import com.xu.crawler.dao.TargetUrlsDao;
import com.xu.crawler.dao.entity.TargetUrlsDO;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class TargetUrlsDaoImpl implements TargetUrlsDao {

    @Resource
    private MongoTemplate mongoTemplate;

    @Override
    public List<TargetUrlsDO> queryTargetUrls() {
        return mongoTemplate.findAll(TargetUrlsDO.class);
    }

    @Override
    public void saveTargetUrls(List<TargetUrlsDO> targetUrlsDOs) {
        targetUrlsDOs.forEach(tempTargetUrlDO -> {
            mongoTemplate.insert(tempTargetUrlDO);
        });
    }
}
